<script type="text/javascript" src="script/jquery-1.4a2.min.js"></script>
<script type="text/javascript">
    function getHTML(v){
        if(v>0){
            $.post("ajax_back_end.php",  
	{train_cat: v},  
	function (data){ 
	    if(data !=2){		
                 document.getElementById('cats').style.display="block";
                 document.getElementById("cats").innerHTML=data;
		}else{
                    document.getElementById('cats').style.display="none";
                 document.getElementById("cats").innerHTML="";
                }
	});  
        }else{
             document.getElementById('cats').style.display="none";
                 document.getElementById("cats").innerHTML="";
        }
    }
    function check_from(){
        $res='1';
        var title=document.getElementById('title').value;
        var cat=document.getElementById('cat').value;
        var cats=document.getElementById('cats').value;
        var smalltext=document.getElementById('smalltext').value;
        var video=document.getElementById('video').value;
        
        if(title == ''){
            document.getElementById("title_span").innerHTML="<font class='red'>视频标题不能为空！</font>";
            $res='0';
        }else{
            document.getElementById("title_span").innerHTML="";
        }
        if(cat == ''||cats==''){
            document.getElementById("cat_span").innerHTML="<font class='red'>请选择视频分类！</font>";
            $res='0';
        }else{
            document.getElementById("cat_span").innerHTML="";
        }
        if(smalltext == ''){
            document.getElementById("smalltext_span").innerHTML="<font class='red'>视频简介不能为空！</font>";
            $res='0';
        }else{
            document.getElementById("smalltext_span").innerHTML="";
        }
        if(video == ''){
            document.getElementById("video_span").innerHTML="<font class='red'>请添加要上传的视频文件！</font>";
            $res='0';
        }else{
            document.getElementById("video_span").innerHTML="";
        }
        if($res=='0'){
            return false;
        }else{
            return true;
        }
        
    }
    function check_input(id){
        var inputval =document.getElementById(id).value;
        
        if(inputval == ''){
            document.getElementById(id+"_span").innerHTML="<font class='red'>必填，不能为空！</font>";
        }else{
            document.getElementById(id+"_span").innerHTML="";
        }
    }
    
</script>
<style>
    .admin_table span{
        padding: 0 10px;
    }
</style>
<div class="admin_right_top">发布培训视频</div>
<form enctype="multipart/form-data" method="post" action="" onsubmit="return check_from()">
    <input type="hidden" name="max_file_size" value="32000000">
<table cellspacing="1" cellpadding="7" border="0" bgcolor="#DDDDDD" class="admin_table">
    <tr> 
        <td width="13%" bgcolor="#EAEFF3" align="left">视频标题<font color="red">*</font></td>
        <td bgcolor="#FFFFFF">
            <input id="title" onblur="check_input(this.id)" type="text" name="title" value="" size="60"><span id="title_span"></span>
        </td>
    </tr>
    <tr> 
        <td width="13%" bgcolor="#EAEFF3" align="left">视频分类<font color="red">*</font></td>
        <td bgcolor="#FFFFFF">
            <select id="cat" name="cat" onchange="getHTML(this.value)" style="float: left;">
                <option>请选择分类</option>
                <{foreach from=$tcat item=list}>
                <option value="<{$list.id}>"><{$list.name}></option>
                <{/foreach}>
            </select>
            <select id="cats" class="noview" name="cats" style="display: none;float: left;">
                <option></option>
            </select>
            <span id="cat_span"></span>
        </td>
    </tr>
    <tr> 
        <td width="13%" bgcolor="#EAEFF3" align="left">视频售价</td>
        <td bgcolor="#FFFFFF">
            <input type="text" value="" name="price" size="5">元（不填默认为免费视频）
        </td>
    </tr>
    <tr> 
        <td width="13%" bgcolor="#EAEFF3" align="left">视频简介<font color="red">*</font></td>
        <td bgcolor="#FFFFFF">
            <textarea id="smalltext" onblur="check_input(this.id)" name="smalltext" cols="58"></textarea><span id="smalltext_span"></span>
        </td>
    </tr>
    <tr> 
        <td width="13%" bgcolor="#EAEFF3" align="left">上传视频<font color="red">*</font></td>
        <td bgcolor="#FFFFFF">
            <input id="video" type="file" name="video"><span id="video_span"></span>
        </td>
    </tr>
    <tr>
        <td width="13%" bgcolor="#EAEFF3" align="left">视频描述</td>
        <td bgcolor="#FFFFFF">
            <{if $de.detail}>
              <{$de.detail}>
              <{else}>
              <script type="text/javascript" src="lib/fckeditor/fckeditor.js"></script>
              <script type="text/javascript">
			var oFCKeditor = new FCKeditor( 'detail' ) ;
			oFCKeditor.Config['ToolbarStartExpanded'] = true ;
			<{if $config.language=='en'}>
				oFCKeditor.Config['DefaultLanguage']='en';
			<{else}>
				oFCKeditor.Config['DefaultLanguage']='zh-cn';
			<{/if}>
			oFCKeditor.BasePath		= 'lib/fckeditor/' ;
			oFCKeditor.ToolbarSet	= 'Default' ;
			oFCKeditor.Width=680;
			oFCKeditor.Height=420;
			oFCKeditor.Create() ;
			</script>
              <{/if}>
        </td>
    </tr>
    <tr> 
        <td width="13%" bgcolor="#EAEFF3" align="left"></td>
        <td bgcolor="#FFFFFF">
            <input type="submit" value="提交" name="videoadd"/>
        </td>
    </tr>

</table>
</form>
<div align="right"><{$re.page}></div>